package com.gsit.expenditure.services;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.gsit.expenditure.domain.Customer;
import com.gsit.expenditure.domain.InvoiceStorage;

@Repository("invoiceStorageServices")
public class InvoiceStorageServices {

	@PersistenceContext
	private EntityManager entityManager;

	@Transactional
	public List<InvoiceStorage> findAll() {
		return null ;// entityManager.createNamedQuery("Customer.findAll",Customer.class).getResultList();
	}

	@Transactional
	public <T> T find(Class<T> entityClass, Long id) {
		return entityManager.find(entityClass, id);
	}

	@Transactional
	public InvoiceStorage saveOrUpdate(InvoiceStorage entity) {
		return entityManager.merge(entity);
	}

	@Transactional
	public void delete(InvoiceStorage entity) {
		entityManager.remove(entityManager.merge(entity));
	}
	
/*	@Transactional
	public List<Customer> findByInvoiceNumber(String invoiceNumber) {
		Query query = entityManager.createQuery("SELECT invoiceStorage FROM InvoiceStorage invoiceStorage where firstName like '%"  + invoiceNumber + "%'");
		return query.getResultList();
	}*/
	

}
